package com.quwan.manager.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.quwan.common.result.PageResult;
import com.quwan.manager.controller.dto.OrderCommentDto;
import com.quwan.manager.service.OrderCommentService;
import com.quwan.mapper.TOrderCommentMapper;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

/**
 * @author laozhang
 * @date 2022/1/13 15:01
 */
@Service
@RequiredArgsConstructor
public class OrderCommentServiceImpl implements OrderCommentService {
    private final TOrderCommentMapper orderCommentMapper;

    @Override
    public PageResult<OrderCommentDto> getOrderCommentListPage(int page, int size, String orderId, String memberName, String content, String beginTime, String endTime,String mId, String commentMemberId) {
        Page<OrderCommentDto> orderCommentPage = orderCommentMapper.selectManagerOrderCommentList(new Page<>(page, size),orderId,memberName,content,beginTime,endTime,mId, commentMemberId);
        PageResult<OrderCommentDto> result = new PageResult<OrderCommentDto>()
                .setCurrent(orderCommentPage.getCurrent())
                .setPages(orderCommentPage.getPages())
                .setSize(orderCommentPage.getSize())
                .setTotal(orderCommentPage.getTotal())
                .setRecords(orderCommentPage.getRecords());
        return result;
    }

    @Override
    public boolean delOrderComment(Integer id) {
        return orderCommentMapper.deleteById(id) == 1;
    }
}
